package cn.pping.controller;

import cn.pping.doc.CourseDoc;
import cn.pping.doc.CourseSearchDto;
import cn.pping.result.JSONResult;
import cn.pping.result.PageList;
import cn.pping.service.ICourseEsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/search")
public class CourseEsController {
    @Autowired
    public ICourseEsService courseEsService;
    @RequestMapping("/saveCourse")
    public JSONResult saveCourseDoc(@RequestBody CourseDoc courseDoc){
        courseEsService.saveCourseDoc(courseDoc);
        return JSONResult.success();

    }


    /**
     * 课程列表页查询
     * @param dto
     * @return
     */
    @PostMapping("/course")
    public JSONResult searchCourse(@RequestBody CourseSearchDto dto){
        PageList<CourseDoc> courseDocs = courseEsService.searchCourse(dto);
        return JSONResult.success(courseDocs);
    }

}
